package com.gotloop.dao;

import java.util.List;

/**
 * Generic Interface for every Data Accessobject.
 * @author jibhaine
 *
 * @param <E> 	The Entity managed by the implementing DAO.
 * @param <ID> 	The Entity primary key.
 */
public interface AbstractDAO<E, ID> {
	
	/**
	 * Persist the Entity.
	 * @param entity	the Entity to persist
	 * @return 			the persisted Entity.
	 */
	E save(E entity);
	
	/**
	 * Persist a list of Entity.
	 * @param entity	the a list of Entities to persist
	 * @return 			the persisted list of Entities.
	 */
	List<E> saveAll(List<E> entity);

	/**
	 * Update an existing entity.
	 * @param entity the Entity to update.
	 */
	void update(E entity);
	
	/**
	 * Delete an Entity.
	 * @param entity the Entity to delete.
	 */
	void delete(E entity);

	/**
	 * Retrieve all Entities.
	 * @return	the list of Entities.
	 */
	List<E> getAll();

	/**
	 * Retrieve an Entity by its primary key.
	 * @param primaryKey 	the Entity primary Key
	 * @return				the Entity or null if not found
	 */
	E getById(ID primaryKey);

}
